package com.imooc.pan.file.feignservice;

import com.imooc.pan.file.entity.RPanUserFile;
import com.imooc.pan.share.entity.RPanUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Janson
 * @Description TODO
 * @Date 2023/8/7
 */
@Component
@Slf4j
public class UserStorageServiceFallbackFactory implements FallbackFactory<UserStorageServiceClient> {
    @Override
    public UserStorageServiceClient create(Throwable cause) {
        return new UserStorageServiceClient() {
            @Override
            public String addUserStorageUsed(Long userId, String fileSizeDesc, Integer folderFlag) {
                log.error("远程调用上传文件的接口发生熔断:{}",cause.toString(),cause);
                return null;
            }
    
            @Override
            public String isFull(Long userId, String fileSizeDesc, Integer folderFlag) {
                log.error("远程调用上传文件的接口发生熔断:{}",cause.toString(),cause);
                return null;
            }
    
            @Override
            public void substracrStorageUsed(Long userId, List<RPanUserFile> reconds) {
                log.error("远程调用上传文件的接口发生熔断:{}",cause.toString(),cause);
            }
    
            @Override
            public RPanUser getUserInfo(Long userId) {
                log.error("远程调用上传文件的接口发生熔断:{}",cause.toString(),cause);
                return null;
            }
        };
    }
    
}
